import { http, httpFormData } from '@/utils/layoutService'

const API = {
  postFileList: '/file/postFileList',
  addFolder: '/file/addFolder',
  addFile: '/file/addFile',
  deleteFile: '/file/delete',
  updateFile: '/file/update',
  getImage: '/file/image',
}

export interface GetPhotoInter {
  parentId: number | undefined
  pageSize: number | undefined
  current: number | undefined
  keyword: string | undefined
}
export interface addFolderInter {
  name: string
  parentId: number
}

export const postFileList = (data: { data: GetPhotoInter }) =>
  http.post(API.postFileList, { data: JSON.stringify(data) })

export const addFolder = (data: { data: any }) =>
  http.post(API.addFolder, { data: JSON.stringify(data) })

export const addFile = (data: { data: any }) =>
  http.post(API.addFile, { data: data })

export const deleteFile = (data: { data: any }) =>
  http.get(API.deleteFile, { params: data })

export const updateFile = (data: { data: any }) =>
  http.post(API.updateFile, { data: data })

export const getImage = (id: { id: string }) =>
  http.get(API.getImage, { params: id })
